require 'stream/pair'

module Lisp

  def cons(head, tail)
    Pair.new(head, tail)
  end

  def car(pair)
    pair.head
  end

  def cdr(pair)
    pair.tail
  end

  def empty
    @@empty
  end

  def is_empty?(pair)
    pair.head == empty && pair.tail == empty
  end

  def list(*elements)
    case elements.size
      when 0 then empty
      else (cons elements.first, (list *elements[1..-1]))
    end
  end

end